﻿
@{
    ViewBag.Title = "岗位管理";
    Layout = "~/Areas/Member/Views/Shared/_form_layout.cshtml";

    string msg = ViewBag.Msg;
    string tips = string.Empty;
    if (!string.IsNullOrWhiteSpace(msg))
    {
        tips = $"layer.msg('{msg}');";
    }
    int positionID = ViewBag.PositionID;
    int departmentID = ViewBag.DepartmentID;
}

<div class="fly-panel fly-panel-user" pad20="">
    <div class="layui-tab layui-tab-brief" lay-filter="user">
        <div class="layui-form layui-tab-content" id="LAY_ucm" style="padding:20px 40px 20px 0;">
            @using (Html.BeginForm(FormMethod.Post, htmlAttributes: new { @class = "layui-form", id = "myForm" }))
            {
                @Html.AntiForgeryToken()
                <input type="hidden" name="empID" value="@ViewBag.EmpID" />
                <div class="layui-form-item">
                    <label class="layui-form-label" for="StartTime">开始时间</label>
                    <div class="layui-input-block">
                        <input type="text" name="StartTime" id="StartTime" lay-verify="date" placeholder="yyyy-MM-dd" data-type="date" autocomplete="off" class="layui-input mydate" data-format="yyyy-MM-dd">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" for="EndTime">结束时间</label>
                    <div class="layui-input-block">
                        <input type="text" name="EndTime" id="EndTime" lay-verify="date" placeholder="yyyy-MM-dd" data-type="date" autocomplete="off" class="layui-input mydate" data-format="yyyy-MM-dd">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" for="MyDepartments">部门</label>
                    <div class="layui-input-block MyDepartments">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label" for="Position">岗位</label>
                    <div class="layui-input-block">
                        <select name="PositionID" id="PositionID"></select>
                    </div>
                </div>

                <div class="layui-form-item">
                    <div class="layui-input-block" style="text-align:right;">
                        <input type="submit" value="提 交" lay-submit="" lay-filter="OAForm" class="layui-btn mySubmit" />
                    </div>
                </div>
            }
        </div>
    </div>
</div>
<script type="text/javascript" src="/Member/Home/GetDepartmentAndPosition"></script>
<script type="text/javascript" src="@ViewBag.OssUrl/front/js/department.js"></script>
<script type="text/javascript">
    layui.use(['form', 'layedit', 'autocomplete', 'element', 'layer', 'laydate'], function () {
        form = layui.form;
        layer = layui.layer;
        element = layui.element;        
        form.on('select(Department)', function (data) {
            InitDepartment($(".MyDepartments"), data.value);
            var currentDepartmentID = data.value;
            if (data.value == "0") {
                if ($(".Department").length > 0) {
                    currentDepartmentID = $(".Department").eq($(".Department").length - 2).val();
                }
            }            
            InitPosition($("#PositionID"), currentDepartmentID, 0);
            form.render('select');
        });
    });
    InitDepartment($(".MyDepartments"), @departmentID);
    InitPosition($("#PositionID"), @departmentID,@positionID);
</script>

